package main

import "fmt"

// 结构体
type person struct {
	name, gender, work string
	age                int
	hobby              []string
}

func main() {
	// 声明一个person类型的变量
	var student person

	// 通过字段赋值
	student.name = "周玲"
	student.gender = "女"
	student.work = "学生"
	student.age = 18
	student.hobby = []string{"排球", "瑜伽"} // student: {周玲 女 学生 18 [排球 瑜伽]}

	// 访问变量
	fmt.Printf("student: %v\n", student)
	fmt.Printf("student.name: %v\n", student.name) // student.name: 周玲

	var docter person
	docter.name = "李想"
	docter.work = "医生"
	// 不赋值会默认赋该类型的零值
	fmt.Printf("docter: %v\n", docter) // docuter: {李想  医生 0 []}

	// 匿名结构体
	var s struct {
		x int
	}
	s.x = 100
	fmt.Printf("s: %v\n", s) // s: {100}
}
